package business.impls.xml;

import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

import java.util.HashMap;

/**
 * User: Programmer
 * Date: 12.04.2006
 * Time: 14:12:21
 */
public class XML_MainConfig_Parser extends DefaultHandler{

    private boolean additionalEnabled = true;
    private String fieldNameProfO ="";
    private String fieldNameProfM ="";
    private String reportPath ="";
    private String departmentName ="";

    public boolean isAdditionalEnabled() {
        return additionalEnabled;
    }

    public String getFieldNameProfO() {
        return fieldNameProfO;
    }

    public String getFieldNameProfM() {
        return fieldNameProfM;
    }

    public String getReportPath() {
        return reportPath;
    }

    public String getDepartmentName() {
        return departmentName;
    }


    public void startElement(String uri, String localName, String qName, Attributes amap) throws SAXException{
        if(localName.equalsIgnoreCase("department")){
            departmentName = amap.getValue("name");
        }

        if(localName.equalsIgnoreCase("additional")){
            additionalEnabled = amap.getValue("enabled").equalsIgnoreCase("true");
        }

        if(localName.equalsIgnoreCase("reports")){
            reportPath = amap.getValue("path");
        }

        if(localName.equalsIgnoreCase("field")){
            if (amap.getValue("name").equalsIgnoreCase("ProfO")) fieldNameProfO = amap.getValue("value");
            if (amap.getValue("name").equalsIgnoreCase("ProfM")) fieldNameProfM = amap.getValue("value");
        }

    }

}
